#ifndef _PHS_HANDLING_
#define _PHS_HANDLING_
#define DBG_IP "10.62.5.244"   //Hardcoded DEBUG IP 

#include<linux/timer.h>
#include<linux/time.h>
#include<linux/jiffies.h>


#include "n_list.h"
#include "page_table.h"
#include "pf_net_mod.h"


#include "io_transfer.h"
#include "parser.h"
#include <linux/blkdev.h>


struct reqtimer{
	struct request* pointer_req;
	struct timer_list* pointer_timer;
};

void phs_debug(char* ipcka, char* vypis);

void send_negative_phs_ack_write_request(struct request* req);

void send_negative_phs_ack_read_request(struct request* req);

int handle_hello(unsigned int source_ip, SwapPacket *packet);

int handle_swap_out_request(unsigned int source_ip, SwapPacket *packet);

int handle_swap_out_reply(unsigned int source_ip, SwapPacket *packet);

int handle_swap_in_request(unsigned int source_ip, SwapPacket *packet);

int handle_swap_in_reply(unsigned int source_ip, SwapPacket *packet);

int hello_init(void);

void hello_exit(void);

int send_hello(void);

int send_swap_out_request(struct request *req, u32 offset_interny, u32 nBytes);

//nie som si isty vstupnymi parametrami
   
int send_swap_out_reply(int flag, int page_id, unsigned int dest_ip, u32 *fyzicka_addr, struct reqtimer* seqnumber);

int send_swap_in_request(struct request *req, u32 offset_interny, u32 nBytes);

int send_swap_in_reply(int flag, int page_id, unsigned int dest_ip, char *data, struct reqtimer* seqnumber);

int switch_handler(unsigned int source_ip, unsigned char *raw_data);

#endif
